<?php

class Search extends Controller{
	
	function Search()
	{
		//Constructor
		parent::Controller();
		$this->load->model('searchmodel');
		$this->load->model('usermodel');
		$this->load->library('form_validation');
	}
	
	function index()
	{
		$this->form_validation->set_rules('search', 'Keyword', 'trim|required|xss_clean');		
		if($this->form_validation->run() == FALSE)
		{
			$data['titlebar'] = 'Panoramap.in.th - Find anyone';
			$this->load->view('search_view', $data);
		}
		else
		{
			$keyword = $this->input->post('search');
			$data['result'] = $this->searchmodel->searchPeople($keyword);
			$data['titlebar'] = 'Panoramap.in.th - Find anyone';
			$this->load->view('search_result_view', $data);
		}
	}
}
